home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjoc85.arc
/
SLIMUTIL.ASM
< prev
next >
Wrap
Assembly Source File
|
1985-08-02
|
8KB
|
218 lines
TITLE ASMUTIL - Assembly language utilities module
TRUE EQU 01H ; boolean true
FALSE EQU 00H ; boolean false
STCRSR EQU 02H ; bios set cursor
SCROLLUP EQU 06H ; bios scroll page
VIDEO_IO EQU 10H ; bios video i/o
EQUIP EQU 11H ; bios equipment selections
SET_CURSOR_TYPE EQU 01H ; bios cursor type option
BREAKINT EQU 1BH ; bios ctrl-break interrupt
SYS_TIMER EQU 1AH ; bios time of day interrupt
DOS_FUNCTION EQU 21H ; dos function call
GETVECTOR EQU 35H ; dos get vector function
SETVECTOR EQU 25H ; dos set vector function
STATUS_PORT EQU 3DAH ; status port address
ASMUTIL SEGMENT PUBLIC 'CODE'
ASSUME CS:ASMUTIL
ASSUME DS:NOTHING
BREAKFLAG DB 0 ; break key hit flag
SAVEBREAK DD 0 ; saved copy of break vect.
;
; function tics: word;
;
; Returns the low word of the system clock.
;
PUBLIC TICS
TICS PROC FAR
MOV AH,0 ; read clock setting
INT SYS_TIMER ; bios time of day
MOV AX,DX ; return value in ax
RET
TICS ENDP
;
; function equipment: word;
;
; Get current bios equipment selections.
;
PUBLIC EQUIPMENT
EQUIPMENT PROC FAR ; return bios equipment list
INT EQUIP ; bios equipment routine
RET ; equip list returned in ax
EQUIPMENT ENDP
;
; procedure set_cursor(row, column: integer);
;
; Position cursor on screen. Assumes video page 0.
;
PUBLIC SET_CURSOR
SET_CURSOR PROC FAR ; set cursor on text page
; with row and col on stack
PUSH BP ; save frame pointer
MOV BP, SP ; get stack top
MOV DH, [BP+8] ; set dh = row
MOV DL, [BP+6] ; set dl = column
MOV BH, 0 ; default to page zero
MOV AH,STCRSR ; set ah = set cursor
INT VIDEO_IO ; call bios video i/o
POP BP ; restore frame pointer
RET 4
SET_CURSOR ENDP
;
; procedure cursor_disappear
;
; Make the cursor invisible.
;
PUBLIC CURSOR_DISAPPEAR
CURSOR_DISAPPEAR PROC FAR
PUSH AX ; save registers
PUSH CX
MOV CH,00100000B ; bit 5 on, bit 6 off
MOV AH,SET_CURSOR_TYPE ; set cursor type option
INT VIDEO_IO ; call bios video i/o
POP CX ; restore registers
POP AX
RET
CURSOR_DISAPPEAR ENDP
;
; procedure cursor_reappear
;
; Makes the normal flat cursor reappear on the screen.
;
PUBLIC CURSOR_REAPPEAR
CURSOR_REAPPEAR PROC FAR
PUSH AX ; save registers
PUSH CX
MOV CH,0BH ; cursor start reg for mono
MOV CL,0CH ; cursor end reg for mono
CALL EQUIPMENT ; ax = bios equipment flags
AND AX,30H ; mask off mono bits
CMP AX,30H ; is this a mono adapter?
JE C1 ; yes, keep mono start & end
MOV CH,06H ; cursor start reg for color
MOV CL,07H ; cursor end reg for color
C1: MOV AH,SET_CURSOR_TYPE ; set cursor type option
INT VIDEO_IO ; call bios video i/o
POP CX ; restore registers
POP AX
RET
CURSOR_REAPPEAR ENDP
;
; procedure clear_screen;
;
; Clear video screen.
;
PUBLIC CLEAR_SCREEN
CLEAR_SCREEN PROC FAR ; clear screen
PUSH BP ; save frame pointer
MOV BP, SP ; get stack top
MOV AL,0 ; blank entire window
MOV CH,0 ; row of upper left corner
MOV CL,0 ; col or upper left corner
MOV DH,24 ; row of lower right corner
MOV DL,79 ; col of lower right corner
MOV BH,7 ; normal attributes
MOV AH,SCROLLUP ; AH = scroll active page up
INT VIDEO_IO ; call bios video i/o
POP BP ; restore frame pointer
RET
CLEAR_SCREEN ENDP
;
; procedure blast_video_ram(addr:ads of byte;output_byte:byte);
;
; Blasts a byte into video ram without causing snow on the
; color/graphics adapter.
;
PUBLIC BLAST_VIDEO_RAM
BLAST_VIDEO_RAM PROC FAR ; update video ram w/o snow
PUSH BP
MOV BP,SP ; bp = top of stack
MOV ES,10[BP] ; es = base of output byte
MOV BX,8[BP] ; bx = offset of output byte
MOV AX,6[BP] ; ax = output byte
POP BP ; restore bp
XCHG AH,AL ; ah = output byte
PUSH DS ; temporarily use ds
PUSH ES ; set ds to es
POP DS ;
MOV DX, STATUS_PORT ; dx = status port
SYNC1: IN AL, DX ; al = status register value
TEST AL, 1 ; test low bit
JNZ SYNC1 ; if not 0 then try again
SYNC2: IN AL, DX ; al = status register value
TEST AL, 1 ; test low bit
JZ SYNC2 ; if 0 then try again
MOV [BX],AH ; blast byte in video ram
POP DS ;
RET 6 ;
BLAST_VIDEO_RAM ENDP
;
; function check_break: boolean;
;
; Checks if ctrl-break has been pressed. It returns TRUE
; if ctrl-break has been pressed and FALSE if it hasn't.
;
PUBLIC CHECK_BREAK
CHECK_BREAK PROC FAR
XOR AX,AX ; clear ax
MOV AL, BREAKFLAG ; return value = breakflag
MOV BREAKFLAG, FALSE ; reset break flag
RET
CHECK_BREAK ENDP
;
; procedure install_break_handler;
;
; Installs a ctrl-break interrupt handler. It also
; saves the address of the former break handler.
;
PUBLIC INSTALL_BREAK_HANDLER
INSTALL_BREAK_HANDLER PROC FAR
PUSH DS
MOV AL,BREAKINT ; al = dos break interrupt
MOV AH,GETVECTOR ; ah = dos get vector funct.
INT DOS_FUNCTION ; call dos
MOV WORD PTR SAVEBREAK,BX ; save off. of int. vec.
MOV WORD PTR SAVEBREAK+2,ES ; save base of int. vec.
MOV AL,BREAKINT ; al = dos break interrupt
MOV AH,SETVECTOR ; ah = dos set vector funct.
MOV DX,OFFSET BREAK_HANDLER ; dx = off. break hndlr
MOV BX,CS ; bx = this segment
MOV DS,BX ; ds = this segment
INT DOS_FUNCTION ; call dos
POP DS
RET
INSTALL_BREAK_HANDLER ENDP
;
; interrupt handler break_handler;
;
; This is invoked by the bios when ctrl_break is pressed.
;
BREAK_HANDLER PROC FAR
MOV BREAKFLAG, TRUE ; breakflag = ctrl-break
IRET ; was pressed
BREAK_HANDLER ENDP
;
; procedure remove_break_handler;
;
; Restores the previous ctrl-break handler.
;
PUBLIC REMOVE_BREAK_HANDLER
REMOVE_BREAK_HANDLER PROC FAR
PUSH DS
MOV AL,BREAKINT ; al = dos break interrupt
MOV AH,SETVECTOR ; ah = dos set vector funct.
MOV DX,WORD PTR SAVEBREAK ; dx = saved offset
MOV BX,WORD PTR SAVEBREAK+2 ; bx = saved base
MOV DS,BX ; ds = saved base
INT DOS_FUNCTION ; call dos
POP DS
RET
REMOVE_BREAK_HANDLER ENDP
ASMUTIL ENDS
END